package com.ang.mybatisplus.base.entity;

import com.ang.annotation.SensitiveEntity;
import com.ang.annotation.SensitiveField;
import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * @author ssang
 * @since 2021-05-10
 */
@Data
@TableName("t_user")
@SensitiveEntity
public class User extends Model<User> {

    private static final long serialVersionUID = 1L;

    //数据库id要设置自增，IdType.ASSIGN_UUID要使用 String 类型
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @SensitiveField
    private String name;

    private Integer age;

    @TableField(fill = FieldFill.INSERT)
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "User{" +
            "id=" + id +
            ", name=" + name +
            ", age=" + age +
        "}";
    }
}
